package resources;

import java.io.InputStream;

import parser.ParseException;
import parser.Parser;
import parser.ParserConstants;
import parser.ParserTokenManager;
import parser.SimpleCharStream;
import semantic.Semantic;
import src.Main;

public class Compilador {

	public Parser parser;
	ParserTokenManager manager;

	public Compilador(InputStream stream) {
		parser = new Parser(stream);
		manager = new ParserTokenManager(new SimpleCharStream(stream));
	}

	public void compilar() {
		try {
			parser.start();
		} catch (ParseException e) {
			System.err.println(e.getMessage());
			Main.window.getTxtConsole().append(
					"ERRO Token:" + parser.token.image + " \t Linha: "
							+ parser.token.beginLine + " \t Coluna: "
							+ parser.token.beginColumn + " \t Tipo: "
							+ ParserConstants.tokenImage[parser.token.kind]
							+ " \t C�digo: " + parser.token.kind + "\n");
		} finally {
			System.out.println(parser.token_source);
		}
	}
	
	public Semantic getSemantic(){
		return parser.semantic;
	}
}